package uk.ac.lkl.lpp.ui;



import java.awt.BorderLayout;
//import java.awt.Component;

//import java.util.HashMap;
//import java.util.Map;
import java.util.logging.Logger;

import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;
import javax.swing.Icon;

//import javax.swing.event.ChangeEvent;
//import javax.swing.event.ChangeListener;

import uk.ac.lkl.lpp.PedagogyPlan;



/**
 * The view of the pedagogy plan.
 * 
 * For moment, assumes use of a JTabbedPane.
 * 
 * @author Darren Pearce
 * @version $Revision$
 * @version $Date$
 * 
 */
public class PedagogyPlanUI extends JPanel {
	private static final long serialVersionUID = 1L;

	private static final Logger logger = Logger.getLogger("uk.ac.lkl.lpp");

    private PedagogyPlan plan;

    private JTabbedPane pane;

    //private HashMap<String, Component> tabMap = new HashMap<String, Component>();


    public PedagogyPlanUI(PedagogyPlan plan) {
        this.pane = new JTabbedPane();
        this.plan = plan;
        setLayout(new BorderLayout());
        add(pane, BorderLayout.CENTER);
    }


    /**
     * Should be a more robust entry point for this really.
     * 
     * @param name
     * 
     */
    public void addTab(String tabName, JComponent component) {
    	logger.fine(tabName+" "+component.toString());
        //tabMap.put(tabName, component);
        JLabel jl = Messages.getJLabel(tabName+"Panel");
        Icon   tabIcon = Messages.getIcon(tabName+".tab");
        String tabTip  = Messages.getTip(tabName+".tab");
        
        JPanel p = new JPanel(new BorderLayout());
        p.add(jl,BorderLayout.NORTH);
        p.add(component,BorderLayout.CENTER);
        
        pane.addTab(tabName, tabIcon, p, tabTip);
    }


    public void clearTabs() {
        pane.removeAll();
    }


    public PedagogyPlan getPlan() {
        return plan;
    }

}
